<template>
  <el-dialog
    :title="view === 'detail'? '商户信息详情': ''"
    :visible="true"
    custom-class="orderDetailWrapper"
    :before-close="closeDialog"
    >
    <vue-body>
    	<el-form :model="tableData" label-width="80px">
    		<el-form-item label="审批编号">
        	<el-input v-model="tableData.applyNo" auto-complete="off" readonly="readonly"></el-input>
      	</el-form-item>
    		<el-form-item label="审批编号">
        	<el-input v-model="tableData.applyNo" auto-complete="off" readonly="readonly"></el-input>
      	</el-form-item>
      	<el-form-item label="申请日期">
        	<el-input v-model="tableData.checkDate" auto-complete="off" readonly="readonly"></el-input>
      	</el-form-item>
      	<el-form-item label="审核状态">
      		<div class="typeBox">
            {{this.tableData.status | status }}
          </div>
      	</el-form-item>
    	</el-form>
       <el-table
            v-loading.body="loading"
            :data="tableData.couponDetailList"
            border
            style="width: 100%">
            <el-table-column
              prop="applyDetailNo"
              label="审批细节编号">
            </el-table-column>
            <el-table-column
              prop="couponNo"
              label="券编号">
            </el-table-column>
            <el-table-column
              prop="couponName"
              label="券名称">
            </el-table-column>
            <el-table-column
              prop="number"
              label="数量">
            </el-table-column>
            <el-table-column
              label="发劵状态">
              <template scope="scope">
                {{ scope.row.couponStatus | couponStatus }}
              </template>
            </el-table-column>
          </el-table>
    </vue-body>
    <div slot="footer" class="dialog-footer">
      <el-button @click="closeDialog">取 消</el-button>
      <el-button type="primary" @click="submit('ruleForm')" v-if="tableData.status != '1'">审核</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { applydetail,checkApply} from "@/services/coupons";
import { RequestError } from "@/services/errors";
import { mapActions } from "vuex";
// import {login} from '@/services/login'
// import menuModules from '@/router/modules.json'
export default {
  name: "edit-role",
  data () {
    return {
      loading: false,
      orderNo:"",
      formData: {
      },
      dialogFormVisible: false,
      tableData: {},
      applyNo:""
    }
  },
  props: {
    view: {
      type: String,
      default: "detail"
    }
  },
  methods: {
    ...mapActions(["setUserInfo"]),
    closeDialog() {
      this.$emit("close");
    },
    async submit() {
      try {
          let data = await checkApply(this.tableData.applyNo)
          this.$emit('close', true)
          this.$message({
            showClose: true,
            message: '审核成功',
            type: 'success'
          })
          this.Subabled = false;
        } catch (e) {
          if (e instanceof RequestError) {
            this.$alert(e.message, '提示', {
              type: 'error',
              confirmButtonText: '确定'
            })
            this.Subabled = false;
          } else {
            throw e
          }
        }
    },
    async loadData () {
        this.loading = true
        try {
          let data = await applydetail(this.applyNo)
          // debugger
//        console.log(data)
          // this.tableData = data.couponDetailList
          this.tableData = data;
        } catch (e) {
          if (e instanceof RequestError) {
            this.$alert(e.message, '提示', {
              type: 'error',
              confirmButtonText: '确定'
            })
          } else {
            throw e
          }
        }
        this.loading = false
      },
  },
  mounted() {
  	
  },
  filters: {
      couponStatus (value) {
      	//订单状态
        return {'0': '未发券', '1': '已发券'}[value]
      },
      status (value) {
      	//配送状态
        return {'0': '未审核', '1': '已审核'}[value]
      },
      payType (value) {
      	//支付方式
        return {'01': '微信支付', '02': '芸券支付','03':'兴业银行'}[value]
      },
      isLogistics(value) {
      	//是否需要物流
        return {'01': '需要', '02': '不需要'}[value]
      },
  },
};
</script>
<style>
.el-select {
  width: 100%;
}
.orderDetailWrapper{
  width: 50%;
}
.typeBox{
	background-color: #fff;
    background-image: none;
    border-radius: 4px;
    border: 1px solid #bfcbd9;
    box-sizing: border-box;
    color: #1f2d3d;
    font-size: inherit;
    height: 36px;
    line-height: 30px;
    outline: 0;
    padding: 3px 10px;
    transition: border-color .2s cubic-bezier(.645,.045,.355,1);
}
.logoImg{
	height: 120px;
	border-radius: 4px;
	border: 1px solid #bfcbd9;
	padding: 5px;
}
</style>
